Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello.
While working on #1854 I ran into a few typing issues that got in the way:
Most types like
Counter,Gauge,Histogram, andSummaryhave both an interface and a concrete private implementation (counter,gauge, etc.) that implements it. But for the vector types (CounterVec,GaugeVec) there’s no interface — they’re implemented directly. I introduced interfaces for these vector types and moved the implementations into private types (counterVec,gaugeVec).The
ObserverVecinterface forHistogramVecandSummaryVecimplements all its methods and also satisfiesCollector. However, forHistogramandSummary, theObserverinterface only definesObserve(float64). This prevents creating a generic interface forHistogramandSummaryin places that require aCollectorimplementation. I added the missing methods toObserverand introduced a newObserverMetodinterface.Added the missing methods to
ObserverVec.All *Vec types use
MetricVecunder the hood. I also turnedMetricVecinto an interface.I tried to maintain maximum backward compatibility to minimize the likelihood of changes in existing projects.
In most cases, everything will work without changes or with minimal changes (for example, replacing type from pointer to the interface --
*CounerVec=>CounerVec)